float x = 100;  
float y = 100;  
float angle1 = 0.0;  
float segLength = 50;  
float mouxeX_old = 0.0;
float mouxeY_old = 0.0;

PFont fontA;

void setup() {
	size(200, 200);
	smooth();   
	strokeWeight(20.0);  
	stroke(0, 100);  
	fontA = loadFont("Arial");
	textFont(fontA, 32);  
}
void draw() {
	background(#454545);

	float dx = mouseX - x;  
	float dy = mouseY - y;  
	angle1 = atan2(dy, dx);    
	x = mouseX - (cos(angle1) * segLength);  
	y = mouseY - (sin(angle1) * segLength);  

	segment(x, y, angle1);   
	ellipse(x, y, 20, 20);  
	
	text(String(canvas_cnt), 30, 60); 
}

void segment(float x, float y, float a) {  
	pushMatrix();  
	translate(x, y);  
	rotate(a);  
	line(0, 0, segLength, 0);  
	popMatrix();  
}

void mouseMoved(){
	if(abs(mouxeX_old-mouseX)>10||abs(mouxeY_old-mouseY)>10){
		mouxeX_old = mouseX;
		mouxeY_old = mouseY;
		//$("#cans_text1").text(mouseX);   
		//$("#cans_text2").text(mouseY);   
	}
}